package main

import (
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/plugins/cors"
	"yunshangxiaozhao/controllers"
	_ "yunshangxiaozhao/routers"
)

func main() {
	if beego.BConfig.RunMode == "dev" {
		beego.BConfig.WebConfig.DirectoryIndex = true
		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
		beego.ErrorController(&controllers.ErrorController{})
	}
	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
		AllowCredentials: true,
		AllowOrigins:     []string{"http://localhost:8080", "http://www.yunshangxiaozhao.com"},
	}))
	//server, _ := socketio.NewServer(nil)
	//controllers.ChatController.CreateServer(nil, server)
	beego.SetStaticPath("/", "static")
	beego.Run()
}
